﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using HotelManagement.Class;

namespace HotelManagement
{
    public partial class GenerateInvoice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string guestId = Request.QueryString["guestId"];
            lblRetrieveGuestID.Text = guestId;

            string title = Request.QueryString["title"];
            lblRetrieveTitle.Text = title;

            string firstName = Request.QueryString["firstName"];
            lblRetrieveFirstName.Text = firstName;

            string lastName = Request.QueryString["lastName"];
            lblRetrieveLastName.Text = lastName;

            string gender = Request.QueryString["gender"];
            lblGender.Text = gender;

            string dob = Request.QueryString["dob"];
            lblDOB.Text = dob;

            string email = Request.QueryString["email"];
            lblEmail.Text = email;

            string mobileNum = Request.QueryString["mobileNum"];
            lblMobile.Text = mobileNum;

            string homeNum = Request.QueryString["homeNum"];
            lblHome.Text = homeNum;

            string address = Request.QueryString["address"];
            lblAddress.Text = address;

            string city = Request.QueryString["city"];
            lblCity.Text = city;

            string state = Request.QueryString["state"];
            lblState.Text = state;

            string zipCode = Request.QueryString["zipCode"];
            lblZip.Text = zipCode;

            string country = Request.QueryString["country"];
            lblCountry.Text = country;

            string itemUsed = Request.QueryString["itemUsed"];
            lblItemsUsed.Text = itemUsed;

            string comment = Request.QueryString["comment"];
            lblComment.Text = comment;

            string extraCharges = Request.QueryString["extraCharges"];
            lblExtraCharges.Text = extraCharges;

            lblExtraChargeRate.Text = extraCharges;

            string arrivalDate = Request.QueryString["arrivalDate"];
            lblArrivalDate.Text = arrivalDate;

            string arrivalTime = Request.QueryString["arrivalTime"];
            lblArrivalTime.Text = arrivalTime;

            string departDate = Request.QueryString["departDate"];
            lblDepartDate.Text = departDate;

            string departTime = Request.QueryString["departTime"];
            lblDepartTime.Text = departTime;

            string numOfNights = Request.QueryString["numOfNights"];
            lblRetrieveNight.Text = numOfNights;

            string numOfAdults = Request.QueryString["numOfAdults"];
            lblAdult.Text = numOfAdults;

            string numOfChildren = Request.QueryString["numOfChildren"];
            lblChildren.Text = numOfChildren;

            string roomNum = Request.QueryString["roomNum"];
            lblRoom.Text = roomNum;

            string roomType = Request.QueryString["roomType"];
            lblRoomType.Text = roomType;

            string remarks = Request.QueryString["remarks"];
            lblRemarks.Text = remarks;

            string bookingId = Request.QueryString["bookingId"];
            lblBookingId.Text = bookingId;

            string area = Request.QueryString["area"];
            lblArea.Text = area;

            string paymentOption = Request.QueryString["paymentOption"];
            lblPayment.Text = paymentOption;

            string cardHolder = Request.QueryString["cardHolder"];
            lblCardHolderName.Text = cardHolder;

            string type = Request.QueryString["type"];
            lblType.Text = type;

            string cardNum = Request.QueryString["cardNum"];
            lblCardNumber.Text = cardNum;

            string expiryDate = Request.QueryString["expiryDate"];
            lblExpiry.Text = expiryDate;

            int bookingIdForSearch=Convert.ToInt32(lblBookingId.Text);
            Invoice i = BookingAndRoomAvailabilityDBManager.GetInvoiceInfoByBookingId(bookingIdForSearch);
            lblInvoiceId.Text = i.InvoiceID.ToString();

            //Room r = BookingAndRoomAvailabilityDBManager.GetRoomInfoByBookingId(bookingIdForSearch);
            string roomNumForSearch=lblRoom.Text;
            Room r = BookingAndRoomAvailabilityDBManager.GetRoomRateByRoomNum(roomNumForSearch);
           
            double roomRate = Convert.ToDouble(r.Rate);

            int totalNight = Convert.ToInt32(lblRetrieveNight.Text);
            double totalRate=roomRate * totalNight;
            lblRate.Text = totalRate.ToString();
            double totalExtraCharge = Convert.ToInt32(lblExtraChargeRate.Text);
            double totalCharge = totalRate + totalExtraCharge;

            lblTotalCharges.Text = totalCharge.ToString();

        }

        protected void btnPrint_Click(object sender, EventArgs e)
        {
            string roomNum = Request.QueryString["roomNum"];
            Room roomStatus=new Room();
            roomStatus.Status="Vacant";
            BookingAndRoomAvailabilityDBManager.UpdateRoomStatusByRoomId(roomStatus, roomNum);
            Server.Transfer("PrintInvoice.aspx");
        }
    }
}